# 使用Python 3.8官方镜像作为基础镜像
FROM hybridgroup/opencv:4.10.0

WORKDIR /app

COPY . /app

ENV PATH=$PATH:/app/bin/

# 配置国内go mod代理
ENV GOPROXY=https://goproxy.cn

# 首先需要安装gocv
RUN go get -u -d gocv.io/x/gocv@v0.37.0
# RUN cd $GOPATH/pkg/mod/gocv.io/x/gocv@v0.37.0 && make install

# 安装paddle_inference_c
ENV CGO_CFLAGS="-I/app/paddle_inference_c/paddle/include"
ENV CGO_LDFLAGS="-L/app/paddle_inference_c/paddle/lib -L/app/paddle_inference_c/third_party/install/cryptopp/lib/ -L/app/paddle_inference_c/third_party/install/utf8proc/lib/ -L/app/paddle_inference_c/third_party/install/mkldnn/lib/ -L/app/paddle_inference_c/third_party/install/onnxruntime/lib/ -L/app/paddle_inference_c/third_party/install/paddle2onnx/lib/ -L/app/paddle_inference_c/third_party/install/mklml/lib/ -L/app/paddle_inference_c/third_party/install/gflags/lib/ -L/app/paddle_inference_c/third_party/install/xxhash/lib/ -L/app/paddle_inference_c/third_party/install/protobuf/lib/"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/app/paddle_inference_c/third_party/install/mklml/lib/:/app/paddle_inference_c/third_party/install/mkldnn/lib/:/app/paddle_inference_c/paddle/lib/:/app/paddle_inference_c/third_party/install/onnxruntime/lib/:/app/paddle_inference_c/third_party/install/paddle2onnx/lib/"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/app/paddle_inference_c/third_party/install/"

# 下载 https://paddle-inference-lib.bj.bcebos.com/2.3.2/cxx_c/Linux/CPU/gcc8.2_avx_mkl/paddle_inference_c.tgz
RUN wget https://paddle-inference-lib.bj.bcebos.com/2.5.2/cxx_c/Linux/CPU/gcc8.2_avx_mkl/paddle_inference_c.tgz
RUN tar -zxvf paddle_inference_c.tgz

# 执行go get下载依赖
#RUN go get github.com/paddlepaddle/paddle/paddle/fluid/inference/goapi@v0.0.0-20240622171259-781693eca8fc
#RUN sed -i 's/PD_ConfigEnableVarseqlen/PD_ConfigEnableTensorRtOSS/g' /go/pkg/mod/github.com/paddlepaddle/paddle/paddle/fluid/inference/goapi@v0.0.0-20240622171259-781693eca8fc/config.go

WORKDIR /app/ocr

RUN go build .

CMD ["/app/ocr/tujiang"]